package lambdasinaction.chap10;

import java.util.Optional;

/**
 * @author bcc
 * @Description:
 * @date 2019-09-18 23:01
 */
public class OptionalUtility {

    public static Optional<Integer> stringToInt(String s){
        try {
            return Optional.of(Integer.parseInt(s));
        } catch (NumberFormatException e){
            return Optional.empty();
        }
    }

    public static void main(String[] args) {
        Optional<Integer> aa = stringToInt("aa");
    }
}
